package xdpm.nhom16.DAO;

import xdpm.nhom16.DTO.TinhThanhDTO;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class TinhThanhDAO extends AbstractDAO<TinhThanhDTO> {
	
	private static final String TABLE_NAME = "TINHTHANH";
	private static final String COLUMN_ID = "MaTinhThanh";
	private static final String[] NAME_COLUMNS = new String[] { COLUMN_ID, "TenTinhThanh" };

	public TinhThanhDAO(SQLiteDatabase db) {
		super(db);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected String getTableName() {

		return TABLE_NAME;
	}

	@Override
	protected String getNameColumnId() {

		return COLUMN_ID;
	}

	@Override
	protected String[] getNameColumns() {

		return NAME_COLUMNS;
	}

	@Override
	protected TinhThanhDTO cusorToDTO(Cursor cursor) {

		TinhThanhDTO result = new TinhThanhDTO();
		result.setMaTinhThanh(cursor.getInt(0));
		if (!cursor.isNull(1))
			result.setTenTinhThanh(cursor.getString(1));
		return result;
	}
}
